#include "cloud.h"

CCloud::CCloud() : CObjects()
{

}

CCloud::~CCloud()
{

}

CCloud::CCloud(int Type, float X, float Y)
{
	reality = 0;
	type = Type;
	pos_x = X;
	pos_y = Y;
}

void CCloud::RenderPieceCloud(int P,float x,float y)
{
	if(P == 1)
		StaticPic->Render(_BackBuffer,x,y,7,0);
	else if(P == 2)
		StaticPic->Render(_BackBuffer,x,y,7,1);
	else if(P == 3)
		StaticPic->Render(_BackBuffer,x,y,7,2);
	else if(P == 4)
		StaticPic->Render(_BackBuffer,x,y,8,0);
	else if(P == 5)
		StaticPic->Render(_BackBuffer,x,y,8,1);
	else if(P == 6)
		StaticPic->Render(_BackBuffer,x,y,8,2);
}

void CCloud::RenderFrame(LPDIRECT3DDEVICE9 d3ddv, int t)
{
	SpriteHandlerSP->Begin(D3DXSPRITE_ALPHABLEND);
	if(type == 1)	
	{
		RenderPieceCloud(4,pos_x,pos_y);
		RenderPieceCloud(5,pos_x+DIS,pos_y);
		RenderPieceCloud(6,pos_x+2*DIS,pos_y);
		RenderPieceCloud(1,pos_x,pos_y-DIS);
		RenderPieceCloud(2,pos_x+DIS,pos_y-DIS);
		RenderPieceCloud(3,pos_x+2*DIS,pos_y-DIS);
	}
	else if(type == 0)
	{
		RenderPieceCloud(4,pos_x,pos_y);
		RenderPieceCloud(6,pos_x+DIS,pos_y);
		RenderPieceCloud(1,pos_x,pos_y-DIS);
		RenderPieceCloud(3,pos_x+DIS,pos_y-DIS);
		
	}
	else if(type == 2)
	{
		RenderPieceCloud(4,pos_x,pos_y);
		RenderPieceCloud(5,pos_x+DIS,pos_y);
		RenderPieceCloud(5,pos_x+2*DIS,pos_y);
		RenderPieceCloud(1,pos_x,pos_y-DIS);
		RenderPieceCloud(2,pos_x+DIS,pos_y-DIS);
		RenderPieceCloud(2,pos_x+2*DIS,pos_y-DIS);
		RenderPieceCloud(3,pos_x+3*DIS,pos_y-DIS);
		RenderPieceCloud(6,pos_x+3*DIS,pos_y);
	}
	SpriteHandlerSP->End();
}